package main.java.com.cooljie.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Created by ACER on 2017/6/12.
 */
@Controller

public class LoginController {
    @RequestMapping(value = "/login",method = RequestMethod.GET)
public String login(){
        System.out.println("get777");
        return "login";
    }

    @RequestMapping(value = "/login",method = RequestMethod.POST)
    public String login(HttpServletRequest request,HttpServletResponse response){
        String username=request.getParameter("username");
        String password=request.getParameter("password");
        System.out.println("post7777");
        if(username.equals("admin")&&password.equals("123")){
            System.out.println("post777");
            request.getSession().setAttribute("admin",username);
        }
        return "redirect:/students/studentList";
    }
}
